package cn.doit.scala.day03

/**
 * @DATE 2021/12/27/11:07
 * @Author MDK
 * @Version 2021.2.2
 * */
object C04_Collect {
  def main(args: Array[String]): Unit = {
    val list: List[Any] = List[Any]("java", "scala", "sql", 12.21, 23.22, 12, 21)
    val list1 = list.filter(_.isInstanceOf[String])
    println(list1)

    //转大写
    println(list.filter(_.isInstanceOf[String]).map(_.asInstanceOf[String].toUpperCase))
    val res = for (elem <- list) yield {
      var str=""
      if(elem.isInstanceOf[String]){
        str = elem.asInstanceOf[String].toUpperCase
      }
      str
    }
    println(res)
    println(res.filterNot(_.equals("")))
    val list2: List[Any] = list.filter(_.isInstanceOf[String])
    val res2 = list2.map(e => e.asInstanceOf[String].toUpperCase)

  }
}
